package com.github.sbb.sherry.console.exception;

import org.springframework.http.HttpStatus;

/**
 * 服务端异常.
 *
 * @author zhangyunan
 */
public class ServerException extends BaseException {

  /**
   * 异常打印日志级别.
   *
   * @see ErrorOutputLogLevelEnum
   */
  @Override
  public ErrorOutputLogLevelEnum getLogLevel() {
    return ErrorOutputLogLevelEnum.ERROR;
  }

  /**
   * Instantiates a new Server exception.
   *
   * @param status       the status
   * @param errorMessage the error message
   */
  public ServerException(HttpStatus httpStatus, ErrorMessage errorMessage) {
    super(httpStatus, errorMessage);
  }

  /**
   * Instantiates a new Server exception.
   *
   * @param code    the code
   * @param message the message
   */
  public ServerException(String code, String message) {
    super(HttpStatus.INTERNAL_SERVER_ERROR, code, message);
  }

  /**
   * Instantiates a new Server exception.
   *
   * @param status  the status
   * @param code    the code
   * @param message the message
   */
  public ServerException(HttpStatus httpStatus, String code, String message) {
    super(httpStatus, code, message);
  }

  /**
   * Instantiates a new Server exception.
   *
   * @param errorMessage the error message
   */
  public ServerException(ErrorMessage errorMessage) {
    super(HttpStatus.INTERNAL_SERVER_ERROR, errorMessage);
  }

  /**
   * Instantiates a new Server exception.
   *
   * @param message the message
   */
  public ServerException(String message) {
    super(HttpStatus.INTERNAL_SERVER_ERROR, ErrorCode.SERVER_ERROR, message);
  }

  /**
   * Instantiates a new Server exception.
   */
  public ServerException() {
    super(HttpStatus.INTERNAL_SERVER_ERROR, ErrorCode.SERVER_ERROR, "网络异常，请稍后重试");
  }
}
